#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

HELP2MAN = help2man
PACKAGE_VERSION = $(shell dpkg-parsechangelog | awk '/^Version:/ {print $$2}')

#bcmserver and log2long do not have -? option
PROGRAMS = asc2log canbusload can-calc-bit-timing candump canfdtest \
cangen cangw canlogserver canplayer cansend cansniffer \
isotpdump isotpperf isotprecv isotpsend isotpserver isotpsniffer isotptun \
jacd jspy jsr testj1939 \
log2asc \
slcan_attach slcand slcanpty

MANPAGES = $(PROGRAMS:%=%.1)

%.1: %
	$(HELP2MAN) --no-info --no-discard-stderr --help-option="-?" --version-string="$< $(PACKAGE_VERSION)" ./$< > $@

%:
	dh $@ --with autoreconf

override_dh_auto_clean:
	rm -f $(MANPAGES)
	dh_auto_clean $@

override_dh_auto_install: $(MANPAGES)
	dh_installman $(MANPAGES)
	dh_auto_install $@
